/*
 * GLShaderProgram.cpp
 *
 *  Created on: 2012/08/12
 *      Author: owner
 */

#include "GLShaderProgram.h"

GLShaderProgram::GLShaderProgram() {
	ref = glCreateProgram();
}

GLShaderProgram::~GLShaderProgram() {
	glDeleteProgram( ref );
	ref = NULL;
}

void GLShaderProgram::attach( GLShader* shader ) {

	glAttachShader( ref, shader->getReferenceId() );

}

void GLShaderProgram::link() {
	glLinkProgram( ref );
}

void GLShaderProgram::use() {
	glUseProgram( ref );
}


int GLShaderProgram::getAttributeLocationIndex( const char* name ) {
	return glGetAttribLocation( ref, name );
}

int GLShaderProgram::getUniformLocationIndex( const char* name ) {
	return glGetUniformLocation( ref, name );
}
